/*
 * Copyright 2007 National Bioinformatics Network
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package dgbgui.modeldocument;

import java.awt.geom.Point2D;
import java.io.Serializable;

public class QueryState implements Serializable {
    
    public QueryState() {
        m_hasPosition = false;
    }
    
    
    /**
     * @return The position part of the state. If no position has been set
     * explicitly, returns null
     */
    public Point2D getPosition() { 
        if ( m_hasPosition ) {
            return new Point2D.Double(m_xPosition,m_yPosition);
        } else {
            return null;
        }
    }
    
    public void setPosition(Point2D position) {
        m_hasPosition = true;
        m_xPosition = position.getX();
        m_yPosition = position.getY();
    }
    
    // -------------- Serilization -------
    
    /**
     * First serilization version
     */
    private static final long serialVersionUID = 1L;

    // This is done like this since Point2D.Double is not serializable (at least
    // not in 1.5). According to this:
    // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4263142
    // it's done in 1.6, but there's no stable version of 1.5 for Mac OS X yet
    double m_xPosition = 0;
    double m_yPosition = 0;
    boolean m_hasPosition = false;


}
